#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> vec(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> vec[i];
    }
    int left = 1,right = 1;
    int max = INT_MIN, best_l = 0, best_r = 0;
    int cur = 0;
    while(right <= n){
        if(cur < 0){
            cur = vec[right];
            left = right;
        }else cur += vec[right];

        if(cur > max){
            best_l = left, best_r = right;
            max = cur;
        }
        right++;
    }
    cout << best_l << ' ' << best_r << '\n';
    return 0;
}